<?php

/**
 * Created by PhpStorm.
 * User: taj
 * Date: 14-9-18
 * Time: 下午4:48
 */
class Controller_Mouthlykc extends Controller
{

    public static function doupcostdate($beginDate,$endDate){
        if(!(isset($beginDate)&&isset($endDate))){
            $beginDate=date('Y-m-01',strtotime('-1 month'));
            $endDate=date('Y-m-01');
        }
        $beginDate=date('Y-m-01',strtotime('-1 month'));
        $endDate=date('Y-m-01');
        var_dump($beginDate);
        var_dump($endDate);exit;
        $warehouseSkus=DB::query(Database::SELECT,'SELECT DISTINCT(`sku`)
FROM `warehouseorders`
WHERE `type`!=10
AND `warehouse_date`>="'.$beginDate.'"
AND `warehouse_date`<"'.$endDate.'"')->execute('newerp')->as_array();
        $deliverySkus=DB::query(Database::SELECT,'SELECT DISTINCT(`sku`)
FROM `deliveryorders`
WHERE `type`!=10
AND `delivery_date`>="'.$beginDate.'"
AND `delivery_date`<"'.$endDate.'"')->execute('newerp')->as_array();
        $updatingSkus=array_merge($warehouseSkus,$deliverySkus);
        var_dump($updatingSkus);exit;
    }


    public function Action_update_kc()
    {
        set_time_limit(0);
        ini_set('memory_limit','1048M');

        $time        = $_GET['start_time'];
        $warehouseid = Kohana::$config->load('warehouse')->warehouse_id;

        Log::instance()
            ->add(log::INFO,"更新库存成本开始时间是：".date('Y-m-d H:i:s'));
        $starttime = $endtime = '';
        if(!isset($_GET['start_time'])){
            $starttime = date('Y-m-01',strtotime('-1 month'));
            $endtime   = date('Y-m-t',strtotime('-1 month'));
        }else{
            $starttime = date('Y-m-01',strtotime($time));
            $endtime   = date('Y-m-t',strtotime($time));
        }

        $qimo_day = date('Y-m-01',strtotime("$starttime +1 month"));//当前月的第一天
        $this::doupcostdate($starttime,$qimo_day);
        //echo $starttime.",".$endtime.",".$qimo_day;exit;
        //先删除当月已经存在的sku
        $sql_de = "DELETE FROM `inventories` WHERE `inventory_date`='".$qimo_day."'";
        DB::query(Database::DELETE,$sql_de)
            ->execute('newerp');
        $sql  = "SELECT `skusystem_skus`.`sku` `products_sku`,
                    `skusystem_cnname`.`name` `products_name_cn`,
                    `skusystem_places`.`place` `products_place`
                    FROM `skusystem_skus`
                    LEFT JOIN `skusystem_sku_cnname`
                    ON `skusystem_sku_cnname`.`sku`=`skusystem_skus`.`sku`
                    LEFT JOIN `skusystem_cnname`
                    ON `skusystem_cnname`.`id`=`skusystem_sku_cnname`.`attr_id`
                    LEFT JOIN `skusystem_place_skus`
                    ON `skusystem_place_skus`.`sku`=`skusystem_skus`.`sku`
                    LEFT JOIN `skusystem_places`
                    ON `skusystem_places`.`id`=`skusystem_place_skus`.`place_id`
                    WHERE `skusystem_skus`.`sku` NOT LIKE '%\\-%'
                    AND `skusystem_skus`.`sku` NOT LIKE ''
                    GROUP BY `skusystem_skus`.`sku`";
        $skus = DB::query(Database::SELECT,$sql)
            ->execute('newerp')
            ->as_array();


        if(!empty($skus)){
            $skus_arrs = array_chunk($skus,5000);
            foreach($skus_arrs as $k => $skus_arr){
                $skus_str   = $skus_str_temp = '';
                $sql_insert = "INSERT INTO `inventories` (`warehouseid`,`inventory_date`, `sku`, `sku_name`, `sku_standard`, `storage_position`) VALUES";
                foreach($skus_arr as $sku_info){
                    tool::slashesDeep($sku_info);
                    $skus_str .= "'".$sku_info['products_sku']."',";
                    $skus_str_temp .= $skus_str_temp==''?"($warehouseid,'".$qimo_day."','".$sku_info['products_sku']."','".$sku_info['products_name_cn']."','','".$sku_info['products_place']."')":",($warehouseid,'".$qimo_day."','".$sku_info['products_sku']."','".$sku_info['products_name_cn']."','','".$sku_info['products_place']."')";
                }
                $sql_insert .= $skus_str_temp;
                $skus_str = rtrim($skus_str,',');
                DB::query(Database::INSERT,$sql_insert)
                    ->execute('newerp');
                $sql_select     = "SELECT upper(sku) as sku,sum(num) as num,sum(cost) as cost,
					sum(open_num) as open_num,sum(open_cost) as open_cost,
					sum(in_num) as in_num,sum(in_cost) as in_cost,sum(out_num) as out_num,sum(out_cost) as out_cost from (
				SELECT
					warehouseorders.sku AS sku,
					warehouseorders.warehouse_quantity AS num,
					warehouseorders.cost AS cost,
					0 as open_num,
					0 as open_cost,
					warehouseorders.warehouse_quantity AS in_num,
					warehouseorders.cost AS in_cost,
					0 AS out_num,
					0 AS out_cost
				FROM
					warehouseorders
				WHERE
					warehouseorders.warehouse_date >= '".$starttime."'
				AND
					warehouseorders.warehouse_date <= '".$endtime." 23:59:59'
				AND warehouseorders.sku IN (".$skus_str.")
			    UNION ALL
				SELECT
					`deliveryorders`.`sku` AS `sku` ,
					- (`deliveryorders`.`quantity`) AS `num`,
					- (`deliveryorders`.`cost`) AS `cost`,
					0 as open_num,
					0 as open_cost,
					0 AS in_num,
					0 AS in_cost,
					`deliveryorders`.`quantity` AS out_num,
					`deliveryorders`.`cost` AS out_cost
				FROM
					`deliveryorders`
				WHERE
					`deliveryorders`.`delivery_date` >= '".$starttime."'
				AND
					`deliveryorders`.`delivery_date` <= '".$endtime." 23:59:59'
				AND `deliveryorders`.sku IN (".$skus_str.")
		    	UNION ALL
				SELECT
					`inventories`.`sku` AS `sku`,
					`inventories`.`quantity` AS `num`,
					`inventories`.`cost` as `cost`,
					`inventories`.`quantity` as open_num,
					`inventories`.`cost` as open_cost,
					0 AS in_num,
					0 AS in_cost,
					0 AS out_num,
					0 AS out_cost
				FROM
					`inventories`
				WHERE
					`inventories`.`inventory_date` = '".$starttime."'
					AND `inventories`.sku IN (".$skus_str.")
					) a where 1 GROUP BY sku";
                $select         = DB::query(Database::SELECT,$sql_select)
                    ->execute('newerp')
                    ->as_array();
                //---yuqing--begin----
                // 在分仓之后很多sku都不会出现在一个仓库，就会造成update的时候出现 update inventories  set cost = ( case sku end )
                // 报错，一旦出现没有库存的，立刻跳出此次循环。
                if(!$select){
                    continue;
                }
                //---yuqing---end-----
                $sql_update_num = $sql_update_cost = $sql_update_do = '';
                foreach($select as $key => $_select){
                    $sql_update_num .= " WHEN '".$_select['sku']."' THEN '".$_select['num']."'";
                    $add_temp = $_select['open_num']+$_select['in_num'];
                    //求sku的月末加权平均成本
                    if($add_temp!=0){
                        $_select['single_out_cost'] = ($_select['open_cost']+$_select['in_cost'])/$add_temp;
                    }else{

                        $_select['single_out_cost'] = 0;
                    }
                    $_select['cost'] = $_select['open_cost']+$_select['in_cost']-$_select['single_out_cost']*$_select['out_num'];
                    $sql_update_cost .= " WHEN '".$_select['sku']."' THEN '".$_select['cost']."'";//更新库存成本
                    $sql_update_do .= " WHEN '".$_select['sku']."' THEN quantity*".$_select['single_out_cost'];//更新出库单的成本
                }
                $sql_update = "UPDATE inventories SET quantity=(CASE sku ".$sql_update_num." END),
					cost=(CASE sku ".$sql_update_cost." END) WHERE sku in (".$skus_str.") AND inventory_date = '".$qimo_day."'";
                DB::query(Database::UPDATE,$sql_update)
                    ->execute('newerp');
//                $sql_up_do = "UPDATE deliveryorders SET
//					cost=(CASE sku ".$sql_update_do." END)
//                   WHERE
//                   delivery_date >='".$starttime."'
//                   AND delivery_date<='".$endtime." 23:59:59'
//                   AND sku IN (".$skus_str.")";
//                DB::query(Database::UPDATE,$sql_up_do)
//                    ->execute('newerp');
            }
        }
        //删除赛为的无用产品
        $sql_del = "DELETE FROM inventories WHERE sku IN ('0','1','10100','1020','10308','10309','10313','10314','10318','10323','10324','10325','10326','10328','10340','10347','10350','10351','10352','10353','10354','10355','10357','10360','10361','10362','10364','10365','10366','10367','10369','10370','10373','10376','10384','10388','10389','10390','10391','10392','10395','10401','10402','10404','10408','10423','10424','10425','10426','10427','10428','10429','10430','10433','10434','10439','10443','10445','10446','10449','10451','10484','10486','10487','10488','10489','10490','10491','10492','10493','10499','10500','10523','10527','10543','10545','10546','10547','10548','10549','10550','10551','10556','10560','10561','10562','10563','10564','10565','10566','10567','10569','10570','10573','10574','10577','10585','10587','10591','10592','10598','10604','10605','10607','10614','10645','10655','10663','10666','10684','10685','10689','10694','10695','10702','10710','1072','10727','10734','10737','10739','10740','10741','10787','10788','10792','10795','10797','10801','1081','10813','10814','10821','10824','10826','10830','10831','10832','10836','10843','10845','10848','10852','10853','10854','10855','10856','10858','10866','10887','10888','10889','10893','10894','10895','10896','10897','10898','10899','10900','10901','10902','10903','10904','10905','10906','10907','10908','10909','10910','10911','10912','10914','10915','10924','10925','10926','10927','10929','10930','10932','10944','10945','10946','10950','10952','10953','10954','10955','10956','10957','10958','10959','10960','10961','10962','10963','10964','10965','10966','10981','1099','10990','10993','10996','10998','1102','11140','1118','113','11566','11568','11569','11576','11580','11589','11594','11601','11606','11607','11608','11609','11610','11611','11612','11613','11615','11616','11627','11628','11636','11637','11673','11674','11676','11677','11684','11685','11689','11697','11709','11756','11758','11771','11775','11776','11777','11778','11779','11780','11781','11782','11783','11784','11785','11787','11789','11791','11797','11798','11799','11800','11801','11804','11812','11815','11817','11818','11819','11821','11822','11823','11824','11852','11878','11880','11881','11883','11884','11896','11898','11899','11900','11912','11984','11985','11986','11987','11988','11989','11990','12058','12062','12066','12071','12094','12095','12096','12097','12101','12102','12104','12114','12119','12133','12134','12135','12136','12140','12154','12156','12157','12161','12173','12176','12208','12209','12211','12213','12215','12219','12221','12226','12227','12236','12238','12246','12252','12254','12255','12257','12258','12260','12261','12266','12267','12268','12269','12296','12298','1230','12301','12306','12311','12319','12338','12339','12341','12342','12345','12347','12362','12379','12380','12381','12384','12388','12389','12390','12392','12394','12399','12402','12405','12406','12412','12413','12416','12417','12434','12435','12436','12437','12462','12463','12464','12465','12467','12483','12484','12485','12487','12489','12490','12491','12492','12498','12500','12503','12506','12507','12548','12551','12554','12582','12592','12594','12596','12623','12624','12625','12627','12634','12635','12681','12687','12689','12690','12719','12727','12730','12736','12741','12743','12769','12818','12819','12829','12840','12841','12845','12849','12878','12880','12881','12882','12889','1290','1294','12988','12989','1299','12991','12993','12997','13000','1304','13477','1353','1366','1397','13978','13981','13985','13990','13991','14041','14044','14087','14132','14133','14134','14135','1422','14243','14301','1434','14365','14366','14434','14436','14439','14457','1460','14632','14633','14634','14635','14636','14637','14638','14639','14640','14641','14642','14643','14644','14645','14646','14647','14648','14649','14650','14651','14652','14653','14654','14655','14656','14657','14658','14659','14660','14661','14662','14663','14664','14665','14666','14667','14668','14669','14670','14671','14672','14674','14675','1468','14681','14682','14683','14686','14687','14689','14693','14695','14696','14697','14698','14699','14705','14711','1474','14740','14746','14751','1477','14771','14775','14778','14781','14782','14783','14784','14785','14786','14787','14788','14789','14790','14793','14817','14820','14828','14836','14837','14842','14843','14844','1485','1487','1488','14903','1492','14928','14933','14936','14937','1496','14961','14962','1497','14974','14991','14992','14993','14994','14995','15','15036','15064','15065','15066','15067','15068','15069','15070','15071','15072','15116','15119','15120','15126','15135','15136','15140','15143','15144','15145','15151','15152','15153','15154','15155','15156','15157','15158','15159','15161','15162','15178','15181','15183','15184','15185','15186','15188','1519','15208','15209','15210','15211','15213','15220','15222','15223','15224','15225','15226','15227','15228','15229','15230','15231','15234','15245','15246','15248','1525','15250','15253','15255','15261','15263','15264','15268','15269','15270','15271','15272','15273','15275','15276','15277','15278','15279','1528','15280','15282','15283','15284','15285','15286','15287','15288','15294','15305','15308','15309','15314','15354','15355','15356','15357','15391','15392','15393','15394','15395','15396','15397','15398','15399','15400','15401','15402','15403','15421','15423','15435','15436','15437','15452','15453','15468','15469','15470','15471','15472','15473','15474','15475','15476','15477','15478','15481','15482','15483','15484','15485','15487','15488','15492','1550','15501','15502','15503','15505','15510','1552','15527','15529','1553','15537','15541','15542','15545','15547','15548','15549','15551','15552','15554','15556','1556','15562','15563','15564','15565','15566','15569','1557','15571','15573','15574','15575','15576','15577','15578','15579','1558','15580','1560','1561','15628','15638','1566','1567','1569','1579','1581','1582','1584','1585','1587','1589','1592','1594','1597','1599','16','1600','16114','16115','1614','16244','16298','16375','1645','1647','16477','16479','16547','1666','1667','16676','1668','1670','1671','1674','16991','16992','16993','16994','1702','17093','17107','17111','17115','17145','17146','1721','17216','1726','17269','1727','17270','17271','17272','17507','17510','1753','17536','1757','1759','17632','17635','17687','17688','17689','17690','17691','17692','1775','17782','17833','17848','17876','1798','1799','17991','18008','18009','18073','18074','18088','18146','18149','18152','18154','18168','18203','18221','18222','18248','18299','18303','18333','18343','18353','18359','18360','18374','18397','18398','18435','18446','18452','18455','18456','18458','18459','18460','18467','18476','1848','18482','18490','18497','18517','18518','18519','18525','18564','18566','18593','18602','18628','18630','18645','18646','18647','18648','18649','18650','18688','18730','18732','1874','1875','18797','18798','18824','18825','18840','18866','18873','18902','18912','18931','18960','18961','18962','18963','18964','18990','18991','18994','190','19009','19018','19021','19079','19080','19086','19091','19095','19101','19102','19103','19104','19106','19109','1911','19110','19111','19114','19119','19123','19124','19125','19126','19127','19128','19129','19130','19131','19132','19134','19139','19149','19177','19179','19181','19185','192','1920','19214','19221','19238','19265','1927','19273','19274','19298','193','19300','19313','19316','19317','19318','19319','19320','19321','19322','19323','19324','19336','19337','19338','19344','19345','19346','19347','19348','19349','19350','19364','19373','19381','19382','19383','19384','19387','19455','19460','19463','19469','19483','19484','19485','19486','19488','19496','19497','19498','19499','195','19530','19531','19532','19533','19534','19535','19536','19537','19538','19539','19540','19541','19542','19543','19544','19545','19546','19547','19548','19549','19550','19551','19552','19553','19562','19563','19564','19565','19578','19594','19606','19607','19610','19611','19614','19615','19619','1963','1965','19655','1966','19662','1967','1968','1969','19693','19694','1970','1971','19712','1972','19725','19726','19727','19728','19729','19730','19731','19749','19762','19763','19764','19771','19772','19773','19774','19798','19799','19802','19806','19816','19817','19818','19819','19860','19861','1988','19884','19896','19897','19913','19914','19915','19916','19923','19924','19935','19955','19962','19963','19964','19965','19966','2000','20007','20008','2001','20015','2002','20038','20039','2004','20041','20045','20046','20047','20096','20112','201305201627','20137','20139','2015','20152','20153','20154','2016','2017','20175','20176','2018','20189','20190','20192','20201','2025','2029','2030','2031','2035','2036','2037','2038','2039','2040','2041','2042','2045','2047','2048','205','2053','2055','2056','206','2064','2069','2070','2073','2076','2078','2081','2083','2084','2086','2092','2094','2098','213','215','2153','2154','2155','2156','2157','2159','2160','2167','2168','2169','2172','2173','2182','2183','220','2265','2276','2277','2278','2279','2284','2285','2286','2288','2289','2290','2300','2302','2303','2304','2305','2306','2311','2314','2322','2328','2330','2350','2402','2415','2420','2421','2423','2424','2426','2430','2431','2432','2435','2436','2438','2439','2449','2497','2518','2548','2550','2571','2572','2639','2648','2654','2658','2662','2663','2664','2668','2686','2687','2691','2692','2693','2694','2705','2710','2711','2717','2731','2733','2742','2743','2746','2749','2750','2756','2757','2763','2764','2767','2768','2778','2779','2780','2781','2787','2789','2793','2795','2797','2822','2834','2835','2845','2846','2847','2848','2850','2851','2852','2861','2862','2863','2865','2875','2885','2886','2891','2892','2893','2900','2902','2906','2915','2935','2942','2943','2945','2946','2949','2950','2956','2957','2986','2988','299','2991','2993','2994','2995','2996','2997','2998','2999','3','3025','3026','3035','3036','3038','3043','3045','3054','3060','3061','3064','3065','3066','3070','3071','3072','3073','3074','3075','3076','3079','308','3088','3089','3092','3093','3094','3095','3096','3097','3098','3099','3100','328','339','344','347','348','3904','3905','3908','3950','3952','3953','3955','3956','3957','3958','3961','3965','3966','3967','3968','3969','3970','3971','3972','3973','3974','3975','3978','3980','3982','3987','3994','3996','3997','3998','4000','4001','4003','4004','4005','4012','4013','4014','4015','4038','4041','4043','4044','4049','4050','4052','4053','4054','4055','4056','4061','4066','4067','4093','4096','4097','4112','4114','4121','4137','4161','4163','4167','4169','4171','4174','4175','4178','4179','4181','4183','4189','4195','4196','4201','4203','4225','4226','4227','4229','4230','4232','4235','4236','4237','4238','4239','4241','4246','4253','4256','4257','4258','4259','4260','4262','4268','4269','4270','4271','4272','4275','4279','4280','4281','4282','4284','4289','4290','4293','4294','4333','4334','4336','4337','4338','4339','4344','4350','4351','4355','4356','4365','4368','4370','4381','4384','4385','4386','4387','4389','4390','4393','4397','4399','4400','4424','4431','4444','4450','4451','4452','4471','4472','4473','4474','4475','4477','4478','4479','4488','4511','4515','4516','4520','4521','4522','4523','4534','4537','4538','4539','4541','4543','4544','4551','4557','4558','4561','4566','4567','4568','4569','4570','4573','4576','4577','4580','4586','459','4602','4610','4617','4621','4624','4634','4650','4678','4681','4682','4686','4692','4696','4697','4699','4701','4703','4705','4708','4709','4711','4712','4713','4714','4715','4736','4737','4738','4740','4741','4742','4743','4744','4745','4747','4748','4750','4762','4764','4768','4769','4770','4771','4773','4775','4778','4779','4780','4787','4815','4816','4821','4829','483','4842','4843','4847','485','4850','4853','4880','4881','4882','4883','4887','4888','4889','4891','4893','4894','4895','4896','4899','4900','4901','4902','4903','4904','4905','4910','4912','4914','4918','4920','4921','4922','4923','4931','4932','4933','4934','4938','4939','4941','4944','4945','4956','496','4964','4977','4979','4983','4985','4988','4989','4994','4997','5','5173','540','5716','5723','5724','5725','5726','5737','5738','5778','5779','5785','5787','5788','5789','5804','5808','5812','5817','5818','5819','5820','5822','5824','5831','5832','5838','5840','5843','5845','5847','5848','5849','5850','5851','5853','5854','5855','5858','5860','5868','5869','5870','5871','5872','5873','5877','5878','5880','5881','5882','5887','5888','5894','5895','5898','5899','5902','5903','5909','5910','5913','5915','5930','5964','5970','5971','5973','5990','5994','5995','5996','5997','5998','5999','6','6000','6002','6023','6024','6027','6058','606','6068','6071','6072','6076','6077','6078','6079','6080','6081','6094','6102','6108','6125','6126','6137','6139','6140','6157','6159','6163','6164','6167','6169','617','6170','6172','6188','6189','619','6190','6191','6192','6204','6209','6224','6225','6227','6228','6230','6232','6238','624','6240','6241','6242','6255','6256','6259','626','6260','6262','6264','6268','6269','6276','628','6281','6313','6314','6315','6316','6324','6325','6329','6355','6356','6357','6358','6361','6362','638','6389','639','6390','6391','6392','6398','6402','6407','6409','6410','6411','6412','6431','6436','6438','6439','6442','6443','6444','6471','6473','6476','6477','6489','6495','6499','6501','6504','6506','6512','6538','6546','6547','6558','6560','6561','6563','6565','6566','6567','6568','6578','6580','6584','6618','6632','6638','6639','6640','6643','6644','6645','6646','6664','6678','6683','6693','6694','6695','6697','6702','6704','671','6718','6719','6722','6723','6727','6738','6740','6746','6748','6749','675','6750','6752','6753','6756','6757','6778','6779','6781','6782','6783','6784','6785','6786','6799','6800','6801','6804','6805','6806','6839','6840','6841','6842','6843','6844','6846','6848','6849','6850','6851','6852','6853','6854','6908','6909','6915','692','6927','6928','6930','6937','6968','6969','6970','6973','6976','710','712','719','726','741','763','764','765','771','776','791','794','796','797','800','801','804','8066-T6','820','821','822','823','8243','8251','8252','8253','8255','826','8260','8261','827','8272','828','8303','8304','8305','8306','8307','8308','8310','8312','8327','833','8330','8334','8336','8339','8342','8359','836','8360','837','8373','8375','8378','8379','838','8386','839','8396','8414','8417','8424','8425','8429','8430','8435','8439','8453','8455','8458','8459','8460','8478','8480','8483','8484','8485','8486','8487','8498','8507','8512','8514','8516','8517','8518','8519','8520','8521','8522','856','8573','8575','8577','8578','8579','8580','8581','8582','8596','8599','8600','8601','8602','8603','8604','8605','8606','8607','8613','8614','8615','8616','8617','8618','8619','862','8620','8621','865','866','867','8677','869','870','872','873','8736','8755','8759','8760','8763','8764','8765','8766','8768','8771','8772','8780','8781','8785','8786','8788','8790','8792','8793','8816','8837','8838','8840','8843','8874','8889','8892','8894','8896','8897','8898','8921','8922','8926','8928','8929','8932','8935','8936','8939','8940','8948','8959','8962','8963','8965','8989','8991','8993','8994','8995','8998','9','917','918','920','921','924','925','926','928','929','932','952','955','956','962','9659','9660','9661','9664','9666','967','9672','9675','9677','968','969','9735','9741','9743','9754','9755','9756','9760','9762','9765','9767','9768','9769','9770','9771','9772','9775','9776','9777','9778','9779','9782','9783','9784','9786','9787','9788','9789','9790','9792','9793','9794','9796','9797','9799','9800','9806','9818','9822','9844','9845','9848','9852','9855','9857','9858','9859','9860','9861','9862','9863','9866','9867','9870','9877','9879','9887','9890','9895','9896','9897','9901','9904','9933','9934','9935','9940','9941','9942','9943','9944','9945','9946','9952','9954','9955','9956','9957','9963','9966','9967','9968','9969','9970','9971','9972','9973','9974','9975','9977','9978','9980','9981','9982','9983','9984','9985','9986')";
        DB::query(Database::DELETE,$sql_del)
            ->execute('newerp');

        Log::instance()
            ->add(log::INFO,"执行的库存成本数据是".$starttime."--".$endtime.",期末时间是".$qimo_day."\n");
        Log::instance()
            ->add(log::INFO,"更新库存成本的结束时间是：".date('Y-m-d H:i:s'));
        echo 'ok';
    }

}